/**
 * @file    slist.c
 * @author  Azolla (1228449928@qq.com)
 * @brief   static list
 * @version 0.1
 * @date    2025-04-15
 *
 * @copyright Copyright (c) 2025
 * */
#if 0

#define TAG                 "slist"
#define LOG_SET_LEVEL        LOG_LEVEL_DBG
#include "log_level.h"       /*!< Must be placed after LOG_SET_LEVEL >*/


#include <slist.h>
// https://github.com/zephyrproject-rtos/zephyr/blob/main/tests/unit/list/slist.c
static sys_slist_t slist;

/* test iterator from a node */
struct data_node {
    sys_snode_t node;
    int data;
};

static struct data_node test_node[10];

void slist_test(void)
{
    sys_snode_t *node = NULL;

    sys_slist_init(&slist);

    /* Appending node */
    for (int i = 0; i < 10; i++) {
        test_node[i].data = i + 1;
        sys_slist_append(&slist, &test_node[i].node);
    }

    /* Finding and removing node */
    for (int i = 0; i < 3; i++) {
        sys_slist_find_and_remove(&slist, &test_node[i].node);
    }

    /* Inserting node 4 after node 2 */
    sys_slist_insert(&slist, &test_node[2].node, &test_node[6].node);

    /* Getting node  */
    for (int i = 0; i < 10; i++) {
        node = sys_slist_get(&slist);
        if (node == NULL) break;
        LOGI("expected %d got %d", i, ((struct data_node *)node)->data);
    }
    LOGI("%s end...", __func__);
}
#endif

